package com.crazy.crazytransactionservice.controller;

import com.crazy.crazycommon.common.BaseResponse;
import com.crazy.crazycommon.common.ResultUtils;
import com.crazy.crazymodel.model.dto.redeem.RedeemRequest;
import com.crazy.crazymodel.model.vo.RedeemVO;
import com.crazy.crazymodel.model.vo.SubscribeVO;
import com.crazy.crazytransactionservice.service.RedeemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@RequestMapping("/transaction")
@Slf4j
public class RedeemController {
    @Resource
    private RedeemService redeemService;

    /**
     * 赎回
     * @param redeemRequest
     * @return
     */
    @PostMapping("/redeem/getBack")
    public BaseResponse<RedeemVO> redeem(@RequestBody RedeemRequest redeemRequest){
        int customerID = redeemRequest.getCustomerID();
        int productID = redeemRequest.getProductID();
        BigDecimal share =redeemRequest.getShare();
        String bankCardNumber = redeemRequest.getBankCardNumber();

        RedeemVO redeemVO = redeemService.redeem(customerID,productID,share,bankCardNumber);
        return ResultUtils.success(redeemVO);
    }
}
